package com.zpark.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;

/**
 * @PackageName: com.zpark.controller
 * @ClassName: FiltersController
 * @Description:
 * @author: RZS
 * @date: 2022/12/6  11:19
 */
@RestController
@RequestMapping("/user")
public class FiltersController {

    @RequestMapping("/token")
    public String fun1(HttpServletRequest request) {
        StringBuilder builder = new StringBuilder();
        // 获取请求头信息
        String token = request.getHeader("token");
        builder.append(token);
        builder.append("\n");
        // 获取所有请求头
        Enumeration<String> names = request.getHeaderNames();
        while (names.hasMoreElements()) {
            builder.append(names.nextElement());
            builder.append("\n");
        }

        return builder.toString();
    }
}
